f = open('matchdata/performance/node.csv', 'r', encoding='utf-8')
f2 = open('matchdata/performance/link.csv', 'r', encoding='utf-8')
# f = open('matchdata/function/node.csv', 'r', encoding='utf-8')
# f2 = open('matchdata/function/link.csv', 'r', encoding='utf-8')
cnt = 0
data = dict()
type_mp = {
    '核心层': 0,
    '核心-汇聚层': 1,
    '汇聚层': 2,
    '汇聚-接入层': 3,
    '汇聚接入层': 3,
    '接入层': 4
}
type_cnt = dict()
for line in f.readlines():
    cnt += 1
    if cnt == 1:
        continue
    a, b, c = line.strip().split(',')
    data[a] = [int(c), b]
    if b not in type_cnt:
        type_cnt[b] = 0
    type_cnt[b] += 1
for key in type_cnt:
    print(key, type_cnt[key])
print()
cnt = 0
link_type_cnt = dict()
for line in f2.readlines():
    cnt += 1
    if cnt == 1:
        continue
    a, b, c, d = line.strip().split(',')
    type_b = data[b][1]
    type_c = data[c][1]
    if type_b > type_c:
        type_b, type_c = type_c, type_b
    key = type_b + ':' + type_c
    if key not in link_type_cnt:
        link_type_cnt[key] = 0
    link_type_cnt[key] += 1
    if type_mp[type_b] == 4 and type_mp[type_c] == 1:
        print(b, c)
for key in link_type_cnt:
    print(key, link_type_cnt[key])
